

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="深海火锅店">
  <meta name="keywords" content="">
  
    <meta name="description" content="Docker环境配置 安装VirtualBox 安装vagrant 安装完成vagrant后重启一下系统 验证vagrant是否安装成功 cmd输入vagrant，是否有命令提示    使用vagrant创建虚拟机——官方镜像仓库 1vagrant init centos&#x2F;7  此时在E盘已经生成了一个名为“Vagrantfile”的文件	 启动虚拟环境  123456vagrant up# 如果">
<meta property="og:type" content="article">
<meta property="og:title" content="docker配置">
<meta property="og:url" content="http://example.com/2022/12/14/%E7%B3%BB%E7%BB%9F%E9%85%8D%E7%BD%AE/%E7%BC%96%E7%A8%8B%E9%85%8D%E7%BD%AE/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/Docker%E9%85%8D%E7%BD%AE/docker%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="Docker环境配置 安装VirtualBox 安装vagrant 安装完成vagrant后重启一下系统 验证vagrant是否安装成功 cmd输入vagrant，是否有命令提示    使用vagrant创建虚拟机——官方镜像仓库 1vagrant init centos&#x2F;7  此时在E盘已经生成了一个名为“Vagrantfile”的文件	 启动虚拟环境  123456vagrant up# 如果">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958195.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958546.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958434.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958499.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958293.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958909.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958121.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958706.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958530.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958101.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201959057.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202002537.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202010279.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201959669.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201959677.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202011441.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202011084.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202012285.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202012676.png">
<meta property="article:published_time" content="2022-12-14T08:20:00.000Z">
<meta property="article:modified_time" content="2024-02-15T16:04:49.014Z">
<meta property="article:author" content="深海火锅店">
<meta property="article:tag" content="环境配置">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958195.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>docker配置 - Hexo</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fluid</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/background.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="docker配置"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-12-14 16:20" pubdate>
          2022年12月14日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          11k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          91 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">docker配置</h1>
            
            
              <div class="markdown-body">
                
                <h2 id="Docker环境配置"><a href="#Docker环境配置" class="headerlink" title="Docker环境配置"></a>Docker环境配置</h2><ol>
<li>安装VirtualBox</li>
<li>安装<a target="_blank" rel="noopener" href="https://developer.hashicorp.com/vagrant/downloads">vagrant</a></li>
<li>安装完成vagrant后重启一下系统</li>
<li>验证vagrant是否安装成功<ul>
<li>cmd输入vagrant，是否有命令提示</li>
</ul>
</li>
</ol>
<h2 id="使用vagrant创建虚拟机——官方镜像仓库"><a href="#使用vagrant创建虚拟机——官方镜像仓库" class="headerlink" title="使用vagrant创建虚拟机——官方镜像仓库"></a>使用vagrant创建虚拟机——<a target="_blank" rel="noopener" href="https://app.vagrantup.com/boxes/search">官方镜像仓库</a></h2><p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958195.png" srcset="/img/loading.gif" lazyload alt="001.初始化centos"></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash">vagrant init centos/7<br></code></pre></td></tr></table></figure>

<p>此时在E盘已经生成了一个名为“Vagrantfile”的文件	</p>
<p>启动虚拟环境</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958546.png" srcset="/img/loading.gif" lazyload alt="002.启动虚拟环境"></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs bash">vagrant up<br><br><span class="hljs-comment"># 如果速度很慢，使用提前下载好的CentOS7镜像，速度嘎嘎快</span><br><span class="hljs-comment"># vagrant init centos/7 # 没初始化的，要初始化</span><br>vagrant box add centos/7 CentOS-7-x86_64-Vagrant-2004_01.VirtualBox.box<br>vagrant up<br></code></pre></td></tr></table></figure>



<p>ctrl+c停掉</p>
<figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs ebnf"><span class="hljs-attribute">vagrant ssh</span><br></code></pre></td></tr></table></figure>

<p>提示[vagrant@localhost ~]$  连接成功，此时已经可以在VirtualBox内查看到该虚拟机</p>
<p>若提示 <a href="mailto:&#x76;&#x61;&#103;&#114;&#97;&#110;&#116;&#64;&#49;&#50;&#55;&#x2e;&#48;&#46;&#48;&#x2e;&#x31;">&#x76;&#x61;&#103;&#114;&#97;&#110;&#116;&#64;&#49;&#50;&#55;&#x2e;&#48;&#46;&#48;&#x2e;&#x31;</a>: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).</p>
<p>则输入命令set VAGRANT_PREFER_SYSTEM_BIN&#x3D;0 后再重新连接即可</p>
<p>退出vagrant的方法：输入命令exit</p>
<p>以文本的方式打开Vagrantfile，找到这一行配置</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958434.png" srcset="/img/loading.gif" lazyload alt="003更改网络配置"></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># config.vm.network &quot;private_network&quot;, ip: &quot;192.168.33.10&quot;</span><br></code></pre></td></tr></table></figure>

<p>所以我们需要将虚拟机改为192.168.56.XX</p>
<p>即更改为</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># config.vm.network &quot;private_network&quot;, ip: &quot;192.168.56.10&quot;</span><br></code></pre></td></tr></table></figure>

<figure class="highlight ebnf"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs ebnf"><span class="hljs-attribute">vagrant reload</span><br></code></pre></td></tr></table></figure>

<p>重启虚拟机</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs bash">vagrant ssh<br>ip addr <span class="hljs-comment"># 查看虚拟机ip地址是否已经发生了改变</span><br>ping 192.168.xxx <span class="hljs-comment"># 主机与虚拟机是否互相ping通</span><br></code></pre></td></tr></table></figure>



<h2 id="安装docker"><a href="#安装docker" class="headerlink" title="安装docker"></a>安装docker</h2><p>概念：什么是docker？</p>
<p>虚拟化容器技术。Docker基于镜像，可以秒级启动各种容器。每一种容器都是一个完整的运行环境，容器之间互相隔离。</p>
<h3 id="docker的镜像市场"><a href="#docker的镜像市场" class="headerlink" title="docker的镜像市场"></a><a target="_blank" rel="noopener" href="https://hub.docker.com/">docker的镜像市场</a></h3><p><a target="_blank" rel="noopener" href="https://docs.docker.com/engine/install/centos/">安装docker</a></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs bash">vagrant ssh <span class="hljs-comment"># 连接虚拟机</span><br><br>sudo yum remove docker \<br>                  docker-client \<br>                  docker-client-latest \<br>                  docker-common \<br>                  docker-latest \<br>                  docker-latest-logrotate \<br>                  docker-logrotate \<br>                  docker-engine<br><span class="hljs-comment"># 卸载旧版本的docker</span><br></code></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs bash">sudo yum install -y yum-utils<br><br>sudo yum-config-manager \<br>    --add-repo \<br>    https://download.docker.com/linux/centos/docker-ce.repo<br>    <br>sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin<br><span class="hljs-comment"># 过程需要输入y选择确认</span><br><br><span class="hljs-comment"># 启动docker</span><br>sudo systemctl start docker<br><br><span class="hljs-comment"># 查看docker版本</span><br>docker -v<br><span class="hljs-comment"># 查看docker安装了哪些镜像</span><br>sudo docker images<br><span class="hljs-comment"># 设置docker开机自启动</span><br>sudo systemctl <span class="hljs-built_in">enable</span> docker<br></code></pre></td></tr></table></figure>



<h2 id="镜像加速"><a href="#镜像加速" class="headerlink" title="镜像加速"></a>镜像加速</h2><p>登录阿里云后，进入 控制台，左侧菜单找到 “产品与服务”，选择“容器镜像服务”，选择“镜像工具”，点击“镜像加速器”</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 执行以下四个命令</span><br>sudo <span class="hljs-built_in">mkdir</span> -p /etc/docker<br><span class="hljs-comment">#----------------------------------</span><br>sudo <span class="hljs-built_in">tee</span> /etc/docker/daemon.json &lt;&lt;-<span class="hljs-string">&#x27;EOF&#x27;</span><br>&#123;<br>  <span class="hljs-string">&quot;registry-mirrors&quot;</span>: [<span class="hljs-string">&quot;https://g9nk2v6o.mirror.aliyuncs.com&quot;</span>]<br>&#125;<br>EOF<br><span class="hljs-comment">#----------------------------------</span><br>sudo systemctl daemon-reload<br><span class="hljs-comment">#----------------------------------</span><br>sudo systemctl restart docker<br></code></pre></td></tr></table></figure>



<h2 id="切换root用户"><a href="#切换root用户" class="headerlink" title="切换root用户"></a>切换root用户</h2><p>每次sudo很麻烦？直接切换root用户</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">su root<br><span class="hljs-comment"># 默认密码是vagrant</span><br></code></pre></td></tr></table></figure>



<h2 id="连接XShell"><a href="#连接XShell" class="headerlink" title="连接XShell"></a>连接XShell</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs bash">vagrant ssh<br><br><span class="hljs-comment"># 切换为root用户</span><br>sudo -i<br><br><span class="hljs-comment"># 修改root用户密码</span><br>passwd<br><br>sudo vi /etc/ssh/sshd_config<br><span class="hljs-comment"># 找到PasswordAuthentication yes这一行，去掉前面的#</span><br><span class="hljs-comment"># # To disable tunneled clear text passwords, change to no here!</span><br><span class="hljs-comment"># PasswordAuthentication yes</span><br><span class="hljs-comment"># #PermitEmptyPasswords no</span><br><span class="hljs-comment"># PasswordAuthentication no</span><br><br><span class="hljs-comment"># 保存后退出</span><br><span class="hljs-comment"># 重启sshd服务</span><br>systemctl restart sshd<br><br><span class="hljs-comment"># 使用ssh工具进行连接</span><br></code></pre></td></tr></table></figure>

<p>详情请查看这篇<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_43651260/article/details/128055181">博客</a></p>
<h2 id="安装MySQL"><a href="#安装MySQL" class="headerlink" title="安装MySQL"></a>安装MySQL</h2><p>连接上虚拟机之后</p>
<p>在docker镜像仓库搜索mysql，进入tags可查看版本信息</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment">#------- 安装mysql5.7-----------------</span><br><br><span class="hljs-comment"># docker pull mysql # 会下载最新的mysql</span><br><span class="hljs-comment"># 下载指定版本的mysql，比如5.7</span><br><span class="hljs-comment"># docker pull mysql:5.7</span><br>sudo docker pull mysql:5.7<br><br>sudo docker run -p 3306:3306 --name mysql \<br>-v /mydata/mysql/log:/var/log/mysql \<br>-v /mydata/mysql/data:/var/lib/mysql \<br>-v /mydata/mysql/conf:/etc/mysql \<br>-e MYSQL_ROOT_PASSWORD=root \<br>-d mysql:5.7<br><br><span class="hljs-comment"># 查看mysql是否运行</span><br>docker ps<br><span class="hljs-comment"># 没有查看到容器</span><br><span class="hljs-comment">#  查看,发现容器是退出状态</span><br>docker ps -a<br><span class="hljs-comment"># Exited</span><br><br><span class="hljs-comment"># 运行以下命令</span><br>docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql<br><span class="hljs-comment"># 若依然存在问题,可以停用并删除容器,重新启动mysql</span><br>docker stop $(docker ps -q)<br>docker <span class="hljs-built_in">rm</span> $(docker ps -aq)<br><span class="hljs-comment"># 删除镜像</span><br>docker rmi 镜像<span class="hljs-built_in">id</span><br><span class="hljs-comment"># docker 删除报错:</span><br>Error response from daemon: conflict: unable to delete 8e6aee9da407 (must be forced) - image is referenced <span class="hljs-keyword">in</span> multiple repositories<br><br><span class="hljs-comment"># 解决办法</span><br>docker rmi -f 镜像<span class="hljs-built_in">id</span><br><br><span class="hljs-comment"># docker 服务命令</span><br><span class="hljs-comment"># 启动：</span><br><span class="hljs-comment"># systemctl start docker</span><br><span class="hljs-comment"># 守护进程重启：</span><br><span class="hljs-comment"># systemctl daemon-reload</span><br><span class="hljs-comment"># 重启docker服务：</span><br><span class="hljs-comment"># systemctl restart docker / service docker restart</span><br><span class="hljs-comment"># 关闭：</span><br><span class="hljs-comment"># docker service docker stop / docker systemctl stop docker</span><br><br><span class="hljs-comment"># 问题解决之后------</span><br><br><span class="hljs-comment"># 进入配置文件挂载的目录下</span><br><span class="hljs-built_in">cd</span> /mydata/mysql/conf<br><br><span class="hljs-comment"># 编辑配置文件my.cnf</span><br>vi my.cnf<br><br>[client]<br>default-character-set=utf8<br>[mysql]<br>default-character-set=utf8<br>[mysqld]<br>init_connect=<span class="hljs-string">&#x27;SET collation_connection = utf8_unicode_ci&#x27;</span><br>init_connect=<span class="hljs-string">&#x27;SET NAMES utf8&#x27;</span><br>character-set-server=utf8<br>collation-server=utf8_unicode_ci<br>skip-character-set-client-handshake<br>skip-name-resolve<br><br><span class="hljs-comment"># 重启mysql容器</span><br>docker restart mysql<br><br><span class="hljs-comment"># 设置启动docker时，mysql自启动</span><br>docker update mysql --restart=always<br><br><br><span class="hljs-comment">#------- 安装mysql8.0.20-----------------</span><br><br><span class="hljs-comment">#拉取镜像</span><br>docker pull mysql:8.0.20<br><span class="hljs-comment">#启动镜像,用于拷贝配置文件到宿主机</span><br>docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:8.0.20<br><span class="hljs-comment">#查看是否启动成功</span><br>docker ps -a<br><span class="hljs-comment">#新建挂载目录并拷贝配置文件</span><br><span class="hljs-built_in">mkdir</span> -p /mysqldata/<br>docker <span class="hljs-built_in">cp</span>  mysql:/etc/mysql /mysqldata/<br><span class="hljs-comment">#检查是否运行成功</span><br>docker ps -a<br><br><span class="hljs-comment"># 重启mysql容器</span><br>docker restart mysql<br><br><span class="hljs-comment"># 设置启动docker时，mysql自启动</span><br>docker update mysql --restart=always<br><br><span class="hljs-comment"># 使用Navicat链接mysql</span><br><span class="hljs-comment"># ql自启动</span><br>docker update mysql --restart=always<br></code></pre></td></tr></table></figure>



<h2 id="Redis配置"><a href="#Redis配置" class="headerlink" title="Redis配置"></a>Redis配置</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 下载最新redis镜像</span><br>docker pull redis<br></code></pre></td></tr></table></figure>



<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958499.png" srcset="/img/loading.gif" lazyload alt="1"></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">mkdir</span> -p /mydata/redis/conf<br><span class="hljs-built_in">cd</span> /mydata/redis/conf<br><span class="hljs-built_in">touch</span> redis.conf<br><br>docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data \<br>-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \<br>-d redis redis-server /etc/redis/redis.conf<br></code></pre></td></tr></table></figure>

<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958293.png" srcset="/img/loading.gif" lazyload alt="2"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958909.png" srcset="/img/loading.gif" lazyload alt="3"></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 测试一下redis</span><br>docker <span class="hljs-built_in">exec</span> -it redis redis-cli<br></code></pre></td></tr></table></figure>

<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958121.png" srcset="/img/loading.gif" lazyload alt="4"></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># redis默认配置是没有持久化的</span><br><span class="hljs-comment"># 如果重启redis，再获取之前的数据就获取不到了</span><br><span class="hljs-comment"># 具体命令可查看下图</span><br>vi redis.conf<br><br><span class="hljs-comment"># 【输入 i 进入插入模式】</span><br><span class="hljs-comment"># 开启AOF持久化</span><br>appendonly <span class="hljs-built_in">yes</span><br></code></pre></td></tr></table></figure>

<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958706.png" srcset="/img/loading.gif" lazyload alt="5"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958530.png" srcset="/img/loading.gif" lazyload alt="6"></p>
<h5 id="修改redis的密码"><a href="#修改redis的密码" class="headerlink" title="修改redis的密码"></a>修改redis的密码</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 创建容器时设置密码</span><br><span class="hljs-comment"># docker run -itd --name redis-6379 -p 6379:6379 redis --requirepass 123456</span><br><br><span class="hljs-comment"># 为现有的redis创建密码或修改密码</span><br><span class="hljs-comment">#1.进入redis的容器</span><br>docker <span class="hljs-built_in">exec</span> -it 容器ID bash<br><br><span class="hljs-comment">#2.进入redis目录</span><br><span class="hljs-built_in">cd</span> /usr/local/bin<br><br><span class="hljs-comment">#3.运行命令：</span><br>redis-cli<br><br><span class="hljs-comment">#4.查看现有的redis密码：</span><br>config get requirepass<br><span class="hljs-comment"># 这一步若报错(error) NOAUTH Authentication required.</span><br><span class="hljs-comment"># 是因为redis本身设置有密码，此时需要执行以下命令</span><br>auth password; <span class="hljs-comment"># password是之前设置的redis密码</span><br><br><span class="hljs-comment">#5.设置redis密码</span><br>config <span class="hljs-built_in">set</span> requirepass 密码<br><br><span class="hljs-comment"># 清空redis密码</span><br>config <span class="hljs-built_in">set</span> requirepass <span class="hljs-string">&quot;&quot;</span><br></code></pre></td></tr></table></figure>



<h3 id="安装redis可视化工具"><a href="#安装redis可视化工具" class="headerlink" title="安装redis可视化工具"></a>安装redis可视化工具</h3><p>链接：<a target="_blank" rel="noopener" href="https://pan.baidu.com/s/10z0S6b9mo76CWK9y3spPRg?pwd=51tz">https://pan.baidu.com/s/10z0S6b9mo76CWK9y3spPRg?pwd=51tz</a><br>提取码：51tz<br>–来自百度网盘超级会员V3的分享</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201958101.png" srcset="/img/loading.gif" lazyload alt="7"></p>
<p>点击New Connection右边的按钮，可进入设置页面，设置语言</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201959057.png" srcset="/img/loading.gif" lazyload alt="8"></p>
<h2 id="docker安装ElasticSearch"><a href="#docker安装ElasticSearch" class="headerlink" title="docker安装ElasticSearch"></a>docker安装ElasticSearch</h2><h3 id="1-黑马程序员视频内安装方法："><a href="#1-黑马程序员视频内安装方法：" class="headerlink" title="1.黑马程序员视频内安装方法："></a>1.黑马程序员视频内安装方法：</h3><p>链接：<a target="_blank" rel="noopener" href="https://pan.baidu.com/s/1pGnbmkMjD8RXe5Y4xotfOA?pwd=ihe5">https://pan.baidu.com/s/1pGnbmkMjD8RXe5Y4xotfOA?pwd=ihe5</a><br>提取码：ihe5 </p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202002537.png" srcset="/img/loading.gif" lazyload alt="image-20210510165308064"></p>
<p>将其上传到虚拟机中，然后运行命令加载即可：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sh"><span class="hljs-comment"># 导入数据</span><br>docker load -i es.tar<br></code></pre></td></tr></table></figure>

<p>同理还有<code>kibana</code>的tar包也需要这样做。</p>
<p>运行docker命令，部署单点es：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs sh">docker run -d \<br>	--name es \<br>    -e <span class="hljs-string">&quot;ES_JAVA_OPTS=-Xms512m -Xmx512m&quot;</span> \<br>    -e <span class="hljs-string">&quot;discovery.type=single-node&quot;</span> \<br>    -v es-data:/usr/share/elasticsearch/data \<br>    -v es-plugins:/usr/share/elasticsearch/plugins \<br>    --privileged \<br>    --network es-net \<br>    -p 9200:9200 \<br>    -p 9300:9300 \<br>elasticsearch:7.12.1<br></code></pre></td></tr></table></figure>

<p>命令解释：</p>
<ul>
<li><code>-e &quot;cluster.name=es-docker-cluster&quot;</code>：设置集群名称</li>
<li><code>-e &quot;http.host=0.0.0.0&quot;</code>：监听的地址，可以外网访问</li>
<li><code>-e &quot;ES_JAVA_OPTS=-Xms512m -Xmx512m&quot;</code>：内存大小</li>
<li><code>-e &quot;discovery.type=single-node&quot;</code>：非集群模式</li>
<li><code>-v es-data:/usr/share/elasticsearch/data</code>：挂载逻辑卷，绑定es的数据目录</li>
<li><code>-v es-logs:/usr/share/elasticsearch/logs</code>：挂载逻辑卷，绑定es的日志目录</li>
<li><code>-v es-plugins:/usr/share/elasticsearch/plugins</code>：挂载逻辑卷，绑定es的插件目录</li>
<li><code>--privileged</code>：授予逻辑卷访问权</li>
<li><code>--network es-net</code> ：加入一个名为es-net的网络中</li>
<li><code>-p 9200:9200</code>：端口映射配置</li>
</ul>
<p>运行docker命令，部署kibana</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs sh">docker run -d \<br>--name kibana \<br>-e ELASTICSEARCH_HOSTS=http://es:9200 \<br>--network=es-net \<br>-p 5601:5601  \<br>kibana:7.12.1<br></code></pre></td></tr></table></figure>

<ul>
<li><code>--network es-net</code> ：加入一个名为es-net的网络中，与elasticsearch在同一个网络中</li>
<li><code>-e ELASTICSEARCH_HOSTS=http://es:9200&quot;</code>：设置elasticsearch的地址，因为kibana已经与elasticsearch在一个网络，因此可以用容器名直接访问elasticsearch</li>
<li><code>-p 5601:5601</code>：端口映射配置</li>
</ul>
<p>kibana启动一般比较慢，需要多等待一会，可以通过命令：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sh">docker logs -f kibana<br></code></pre></td></tr></table></figure>

<p>查看运行日志，当查看到下面的日志，说明成功：</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202010279.png" srcset="/img/loading.gif" lazyload alt="image-20210109105135812"></p>
<h3 id="2-网上的安装方法："><a href="#2-网上的安装方法：" class="headerlink" title="2.网上的安装方法："></a>2.网上的安装方法：</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 下载镜像文件</span><br>docker pull elasticsearch:7.4.2<br><br><span class="hljs-comment"># 创建搭载目录</span><br><span class="hljs-built_in">mkdir</span> -p /mydata/elasticsearch/config<br><span class="hljs-built_in">mkdir</span> -p /mydata/elasticsearch/data<br><span class="hljs-built_in">echo</span> <span class="hljs-string">&quot;http.host: 0.0.0.0&quot;</span> &gt; /mydata/elasticsearch/config/elasticsearch.yml<br><br>docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \<br>-e  <span class="hljs-string">&quot;discovery.type=single-node&quot;</span> \<br>-e ES_JAVA_OPTS=<span class="hljs-string">&quot;-Xms64m -Xmx512m&quot;</span> \<br>-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \<br>-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \<br>-v  /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \<br>-d elasticsearch:7.4.2<br><br>docker ps<span class="hljs-comment"># 查看容器状态 up 运行</span><br></code></pre></td></tr></table></figure>

<p>若存在问题，查看这篇<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_38327769/article/details/124847508?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522167101576116800182116891%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=167101576116800182116891&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_click~default-2-124847508-null-null.142%5Ev68%5Econtrol,201%5Ev4%5Eadd_ask,213%5Ev2%5Et3_control1&utm_term=docker%E5%AE%89%E8%A3%85ElasticSearch&spm=1018.2226.3001.4187">博客</a></p>
<p>我这里的问题是启动的时候没问题，但是过一会有自动关闭</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201959669.png" srcset="/img/loading.gif" lazyload alt="1"></p>
<p>解决问题和上方博客中写的一样</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">chmod</span> -R 777 /mydata/elasticsearch/<br><br>docker start elasticsearch<br></code></pre></td></tr></table></figure>

<p>查看运行结果</p>
<p>http:&#x2F;&#x2F;虚拟机ip地址:9200&#x2F; </p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201959677.png" srcset="/img/loading.gif" lazyload alt="2"></p>
<h3 id="安装Kibana"><a href="#安装Kibana" class="headerlink" title="安装Kibana"></a>安装Kibana</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 下载镜像文件</span><br>docker pull kibana:7.4.2<br><br><span class="hljs-comment"># 安装容器</span><br>docker run --name kibana -e ELASTICSEARCH_HOSTS=http://自己的IP:9200 -p 5601:5601 -d kibana:7.4.2<br></code></pre></td></tr></table></figure>

<h2 id="安装ik分词器"><a href="#安装ik分词器" class="headerlink" title="安装ik分词器"></a>安装ik分词器</h2><p><a target="_blank" rel="noopener" href="https://github.com/medcl/elasticsearch-analysis-ik/releases">ik分词器下载地址</a></p>
<h3 id="3-1-在线安装ik插件（较慢）"><a href="#3-1-在线安装ik插件（较慢）" class="headerlink" title="3.1.在线安装ik插件（较慢）"></a>3.1.在线安装ik插件（较慢）</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_"># </span><span class="language-bash">进入容器内部</span><br>docker exec -it elasticsearch /bin/bash<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_"># </span><span class="language-bash">在线下载并安装</span><br>./bin/elasticsearch-plugin  install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.12.1/elasticsearch-analysis-ik-7.12.1.zip<br><span class="hljs-meta prompt_"></span><br><span class="hljs-meta prompt_">#</span><span class="language-bash">退出</span><br>exit<br><span class="hljs-meta prompt_">#</span><span class="language-bash">重启容器</span><br>docker restart elasticsearch<br></code></pre></td></tr></table></figure>

<h3 id="3-2-离线安装ik插件（推荐）"><a href="#3-2-离线安装ik插件（推荐）" class="headerlink" title="3.2.离线安装ik插件（推荐）"></a>3.2.离线安装ik插件（推荐）</h3><h3 id="1）查看数据卷目录"><a href="#1）查看数据卷目录" class="headerlink" title="1）查看数据卷目录"></a>1）查看数据卷目录</h3><p>安装插件需要知道elasticsearch的plugins目录位置，而我们用了数据卷挂载，因此需要查看elasticsearch的数据卷目录，通过下面命令查看:</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sh">docker volume inspect es-plugins<br></code></pre></td></tr></table></figure>

<p>显示结果：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs json"><span class="hljs-punctuation">[</span><br>    <span class="hljs-punctuation">&#123;</span><br>        <span class="hljs-attr">&quot;CreatedAt&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;2022-05-06T10:06:34+08:00&quot;</span><span class="hljs-punctuation">,</span><br>        <span class="hljs-attr">&quot;Driver&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;local&quot;</span><span class="hljs-punctuation">,</span><br>        <span class="hljs-attr">&quot;Labels&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">null</span></span><span class="hljs-punctuation">,</span><br>        <span class="hljs-attr">&quot;Mountpoint&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;/var/lib/docker/volumes/es-plugins/_data&quot;</span><span class="hljs-punctuation">,</span><br>        <span class="hljs-attr">&quot;Name&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;es-plugins&quot;</span><span class="hljs-punctuation">,</span><br>        <span class="hljs-attr">&quot;Options&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">null</span></span><span class="hljs-punctuation">,</span><br>        <span class="hljs-attr">&quot;Scope&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;local&quot;</span><br>    <span class="hljs-punctuation">&#125;</span><br><span class="hljs-punctuation">]</span><br></code></pre></td></tr></table></figure>

<p>说明plugins目录被挂载到了：<code>/var/lib/docker/volumes/es-plugins/_data </code>这个目录中。</p>
<h3 id="2）解压缩分词器安装包"><a href="#2）解压缩分词器安装包" class="headerlink" title="2）解压缩分词器安装包"></a>2）解压缩分词器安装包</h3><p>下面我们需要把课前资料中的ik分词器解压缩，重命名为ik</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202011441.png" srcset="/img/loading.gif" lazyload alt="image-20210506110249144"></p>
<h3 id="3）上传到es容器的插件数据卷中"><a href="#3）上传到es容器的插件数据卷中" class="headerlink" title="3）上传到es容器的插件数据卷中"></a>3）上传到es容器的插件数据卷中</h3><p>也就是<code>/var/lib/docker/volumes/es-plugins/_data </code>：</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202011084.png" srcset="/img/loading.gif" lazyload alt="image-20210506110704293"></p>
<h3 id="4）重启容器"><a href="#4）重启容器" class="headerlink" title="4）重启容器"></a>4）重启容器</h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs shell"><span class="hljs-meta prompt_"># </span><span class="language-bash">4、重启容器</span><br>docker restart es<br></code></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs sh"><span class="hljs-comment"># 查看es日志</span><br>docker logs -f es<br></code></pre></td></tr></table></figure>

<h3 id="5）测试："><a href="#5）测试：" class="headerlink" title="5）测试："></a>5）测试：</h3><p>IK分词器包含两种模式：</p>
<ul>
<li><p><code>ik_smart</code>：最少切分</p>
</li>
<li><p><code>ik_max_word</code>：最细切分</p>
</li>
</ul>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs json">GET /_analyze<br><span class="hljs-punctuation">&#123;</span><br>  <span class="hljs-attr">&quot;analyzer&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;ik_max_word&quot;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;text&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;黑马程序员学习java太棒了&quot;</span><br><span class="hljs-punctuation">&#125;</span><br></code></pre></td></tr></table></figure>

<p>结果：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br></pre></td><td class="code"><pre><code class="hljs json"><span class="hljs-punctuation">&#123;</span><br>  <span class="hljs-attr">&quot;tokens&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;黑马&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">0</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">2</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CN_WORD&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">0</span><br>    <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;程序员&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">2</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">5</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CN_WORD&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">1</span><br>    <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;程序&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">2</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">4</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CN_WORD&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">2</span><br>    <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;员&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">4</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">5</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CN_CHAR&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">3</span><br>    <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;学习&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">5</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">7</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CN_WORD&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">4</span><br>    <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;java&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">7</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">11</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;ENGLISH&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">5</span><br>    <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;太棒了&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">11</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">14</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CN_WORD&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">6</span><br>    <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;太棒&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">11</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">13</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CN_WORD&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">7</span><br>    <span class="hljs-punctuation">&#125;</span><span class="hljs-punctuation">,</span><br>    <span class="hljs-punctuation">&#123;</span><br>      <span class="hljs-attr">&quot;token&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;了&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;start_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">13</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;end_offset&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">14</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;type&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;CN_CHAR&quot;</span><span class="hljs-punctuation">,</span><br>      <span class="hljs-attr">&quot;position&quot;</span> <span class="hljs-punctuation">:</span> <span class="hljs-number">8</span><br>    <span class="hljs-punctuation">&#125;</span><br>  <span class="hljs-punctuation">]</span><br><span class="hljs-punctuation">&#125;</span><br></code></pre></td></tr></table></figure>





<h2 id="3-3-扩展词词典"><a href="#3-3-扩展词词典" class="headerlink" title="3.3 扩展词词典"></a>3.3 扩展词词典</h2><p>随着互联网的发展，“造词运动”也越发的频繁。出现了很多新的词语，在原有的词汇列表中并不存在。比如：“奥力给”，“传智播客” 等。</p>
<p>所以我们的词汇也需要不断的更新，IK分词器提供了扩展词汇的功能。</p>
<p>1）打开IK分词器config目录：</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202012285.png" srcset="/img/loading.gif" lazyload alt="image-20210506112225508"></p>
<p>2）在IKAnalyzer.cfg.xml配置文件内容添加：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;?xml version=<span class="hljs-string">&quot;1.0&quot;</span> encoding=<span class="hljs-string">&quot;UTF-8&quot;</span>?&gt;</span><br><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-keyword">properties</span> <span class="hljs-keyword">SYSTEM</span> <span class="hljs-string">&quot;http://java.sun.com/dtd/properties.dtd&quot;</span>&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">properties</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">comment</span>&gt;</span>IK Analyzer 扩展配置<span class="hljs-tag">&lt;/<span class="hljs-name">comment</span>&gt;</span><br>        <span class="hljs-comment">&lt;!--用户可以在这里配置自己的扩展字典 *** 添加扩展词典--&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">entry</span> <span class="hljs-attr">key</span>=<span class="hljs-string">&quot;ext_dict&quot;</span>&gt;</span>ext.dic<span class="hljs-tag">&lt;/<span class="hljs-name">entry</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">properties</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>3）新建一个 ext.dic，可以参考config目录下复制一个配置文件进行修改</p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs properties"><span class="hljs-attr">传智播客</span><br><span class="hljs-attr">奥力给</span><br></code></pre></td></tr></table></figure>

<p>4）重启elasticsearch </p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs sh">docker restart es<br><br><span class="hljs-comment"># 查看 日志</span><br>docker logs -f elasticsearch<br></code></pre></td></tr></table></figure>

<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301202012676.png" srcset="/img/loading.gif" lazyload alt="image-20201115230900504"></p>
<p>日志中已经成功加载ext.dic配置文件</p>
<p>5）测试效果：</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs json">GET /_analyze<br><span class="hljs-punctuation">&#123;</span><br>  <span class="hljs-attr">&quot;analyzer&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;ik_max_word&quot;</span><span class="hljs-punctuation">,</span><br>  <span class="hljs-attr">&quot;text&quot;</span><span class="hljs-punctuation">:</span> <span class="hljs-string">&quot;传智播客Java就业超过90%,奥力给！&quot;</span><br><span class="hljs-punctuation">&#125;</span><br></code></pre></td></tr></table></figure>

<blockquote>
<p>注意当前文件的编码必须是 UTF-8 格式，严禁使用Windows记事本编辑</p>
</blockquote>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/" class="category-chain-item">环境配置</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/">#环境配置</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>docker配置</div>
      <div>http://example.com/2022/12/14/系统配置/编程配置/环境配置/Docker配置/docker环境配置/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>深海火锅店</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年12月14日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/12/15/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Java/%E9%A1%B9%E7%9B%AE/%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E6%90%AD%E5%BB%BA%E5%89%8D%E5%90%8E%E7%AB%AF%E5%88%86%E7%A6%BB%E9%A1%B9%E7%9B%AE/Vue/03.Vue%E9%A1%B9%E7%9B%AE%E7%BB%93%E6%9E%84/" title="03.vue项目布局">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">03.vue项目布局</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/12/14/%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/MySQL%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/" title="mysql复习">
                        <span class="hidden-mobile">mysql复习</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  
<script src="//cdn.jsdelivr.net/gh/EmoryHuang/BlogBeautify@1.1/DynamicRibbon.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
